home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / suck-2.6 / suck-2 / suck-2.6.3 / sample / get.news.innxmit next >
Text File  |  1996-03-29  |  3KB  |  99 lines

  1. #!/bin/sh
  2. # NOTE: this script probably needs to be run by root.  Most systems will
  3. # not allow normal users to run ctlinnd and innxmit.
  4.  
  5. #BEFORE USING - check to ensure all the paths defined below are correct!!
  6.  
  7. REMOTE_HOST=news.pixi.com
  8. LOCAL_HOST=localhost
  9.  
  10. SPOOLDIR=/usr/spool/news        # base directory for articles to be rposted
  11. NEWSDIR=/usr/lib/news            # base directory for news binaries 
  12. BINDIR=/home/boby/doNews        # base directory for suck rpost and scripts
  13.  
  14. TMPDIR=${BINDIR}            # location for suck.* files
  15. DATADIR=${BINDIR}            # location of sucknewsrc and killfile
  16. MSGDIR=${BINDIR}/Msgs            # where to put MultiFile articles when getting them
  17.  
  18. BATCHFILE=${TMPDIR}/batch        # Name of batchfile to build for rnews or innxmit
  19. SITE=pixi                # name of site
  20. OUTGOING=${SPOOLDIR}/out.going/${SITE}        # location of the list of articles to upload
  21. OUTGOINGNEW=${OUTGOING}.new            # temporarily used during upload of articles
  22.  
  23. SCRIPT=${BINDIR}/put.news        # my filter for rpost
  24. OUTFILE=/tmp/tmp$$            # used by rpost as article after it is filtered
  25.  
  26. RPOST=${BINDIR}/rpost            # my rpost
  27. SUCK=${BINDIR}/suck            # my suck
  28. TESTHOST=${BINDIR}/testhost        # my testhost
  29.  
  30. INNXMIT=${NEWSDIR}/bin/innxmit        # location of INNXMIT
  31. CTLINND=${NEWSDIR}/bin/ctlinnd        # location of CTLINND
  32.  
  33.  
  34.  
  35. # is the local host up and running so we can post articles we download?
  36. ${TESTHOST} ${LOCAL_HOST} -s -e
  37. LOCAL_RESULT=$?
  38.  
  39. # is the remote host up and running so we can download articles?
  40. ${TESTHOST} ${REMOTE_HOST} -s -e
  41. REMOTE_RESULT=$?
  42.  
  43. if [ ${REMOTE_RESULT} -eq 0 -a ${LOCAL_RESULT} -eq 0 ]; then
  44.     
  45.     # download articles
  46.     ${SUCK} ${REMOTE_HOST} -bi ${BATCHFILE} -dt ${TMPDIR} -dm ${MSGDIR} -dd ${DATADIR}
  47.     SUCK_STATUS=$?
  48.  
  49.     if [ ${SUCK_STATUS} -eq 0 ]; then
  50.         echo "Downloaded Articles"
  51.         mv ${DATADIR}/sucknewsrc ${DATADIR}/old.newsrc
  52.         mv ${TMPDIR}/suck.newrc ${DATADIR}/sucknewsrc
  53.         rm ${TMPDIR}/suck.*
  54.         if [ -f ${DATADIR}/suckothermsgs ]; then
  55.             rm ${DATADIR}/suckothermsgs
  56.         fi
  57.     fi
  58.  
  59.     # now upload articles
  60.     if [ -s ${OUTGOING} ]; then
  61.  
  62.         # this is needed by INND so that the outgoing file will be
  63.         # properly flushed and we have a new blank file to work with
  64.         # when we are done
  65.         # First mv the current one to a new file name
  66.         # Since innd already has the file open, it doesn't care 
  67.         # about the rename.
  68.         # The flush will ensure that all articles to be posted have
  69.         # been written out, close off the old one (already renamed)
  70.         # and create a new one.
  71.         mv ${OUTGOING} ${OUTGOINGNEW}
  72.         ${CTLINND} flush ${SITE}
  73.         echo "reloaded ctlinnd"
  74.  
  75.         # outgoing articles to post
  76.         ${RPOST} ${REMOTE_HOST} -b ${OUTGOINGNEW} -p ${SPOOLDIR} -f \$\$o=${OUTFILE} ${SCRIPT} \$\$i ${OUTFILE}
  77.  
  78.         if [ $? -ne 0 ]; then
  79.             echo "Error remote posting"
  80.             exit -1;
  81.         else
  82.             echo "Remotely posted articles"
  83.             rm ${OUTFILE} ${OUTGOINGNEW}
  84.         fi
  85.     fi    
  86.     
  87.     echo "You can hang up the modem now"
  88.  
  89.     if [ ${SUCK_STATUS} -eq 0 ]; then    
  90.         # locally post articles
  91.         ${INNXMIT} ${LOCAL_HOST} ${BATCHFILE}
  92.  
  93.         if [ $? -eq 0 ]; then
  94.             echo "Posted Articles Locally"
  95.             rm -rf ${MSGDIR}
  96.         fi    
  97.     fi    
  98. fi
  99.